include "ServiceBase.thrift"

namespace cpp jztzp
namespace java com.jztzp

struct CommentItem {
  1: required i64 id;
  2: required i32 state;
  3: required i32 article_id;
  4: required i32 sender_id;
  5: required string sender_name;
  6: required string sender_ip;
  7: required i32 time_stamp;
  8: required string content;
}

typedef list<CommentItem> CommentList

struct CommentListResult {
  1: required bool success;
  2: optional string reason;
  3: optional CommentList comments;
}

const i32 kAuditStateMask = 0x03; 
enum AuditState {
    UNAUDITED    = 0x00, // 未审核
    AUDITED_FAIL = 0x01, // 审核未通过
    AUDITED_OK   = 0x02, // 审核通过
    AUDIT_STATE_MAX   = 0x03,
}

service ArticleComment extends ServiceBase.ServiceBase {
  void Post(1: CommentItem item);

  CommentItem GetById(1: i64 id);

  void Delete(1: i64 id);
  void SetAuditState(1: i64 id, 2: AuditState audit);

  CommentListResult GetComments(1: i32 audit_flag, 2: i32 offset, 3: i32 limit);
  CommentListResult GetUserComments(1: i64 sender_id, 2: i32 offset, 3: i32 limit);
  CommentListResult GetArticleComments(1: i64 article_id, 2: i32 offset, 3: i32 limit);
  i32 GetArticleCommentCount(1: i64 article_id);
}

